import React, { Component } from "react";

import FileUpload from './react-fileupload.jsx';
export default class FileUploader extends React.Component{
  render(){
    /*set properties*/
    const options={
      baseUrl:'/manage/product/upload.do',
      fileFieldName:'upload_file',
      dataType:'json',
      chooseAndUpload:true,
      uploadSuccess:(res) =>{
        this.props.onSuccess(res.data)
      },
      uploadError:(err) => {
        this.props.onError(err.message||'上传图片失败')
      },
      
    }
    return (
      <FileUpload options={options}>
        <button ref="chooseAndUpload" className="btn btn-primary btn-xs">请选择图片</button>
        {/* <button ref="uploadBtn">upload</button> */}
      </FileUpload>
    )	        
  }
}
